// bookcap.cpp : Defines the class behaviors for the application.
//

#include "stdafx.h"
#include "bookcap.h"
#include "bookcapDlg.h"
#include "..\caphook\caphook.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif


BEGIN_MESSAGE_MAP(CbookcapApp, CWinApp)
	ON_COMMAND(ID_HELP, &CWinApp::OnHelp)
END_MESSAGE_MAP()


CbookcapApp::CbookcapApp()
{
}

CbookcapApp theApp;


BOOL CbookcapApp::InitInstance()
{
	wchar_t buffer[512];
	wchar_t *pStart = buffer;
	wcscpy(buffer,GetCommandLine());
	if (wcsstr(buffer,_T("-boot")) != NULL) {
		for (size_t i = wcslen(buffer); i > 0; i--)
			if (buffer[i] == '\\') {
				buffer[i] = 0;
				break;
			}

		if (buffer[0] == '\"')
			pStart++;

		SetCurrentDirectory(pStart);
	}

	HANDLE single = CreateMutex(NULL,FALSE,_T("__Single_instance_sonya_reader_264742"));
	if (GetLastError() == ERROR_ALREADY_EXISTS)
		return FALSE;


	INITCOMMONCONTROLSEX InitCtrls;
	InitCtrls.dwSize = sizeof(InitCtrls);
	InitCtrls.dwICC = ICC_WIN95_CLASSES;
	InitCommonControlsEx(&InitCtrls);
	CWinApp::InitInstance();
	CoInitialize( NULL );

	CbookcapDlg dlg;
	m_pMainWnd = &dlg;
	dlg.DoModal();

	return FALSE;
}
